home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / passwrd9.zip / PASSWORD.ASM < prev    next >
Assembly Source File  |  1989-03-15  |  17KB  |  575 lines

  1.     Title pw9.asm
  2.     ;Originally titled PW.8
  3.     ;Rev by John R. Petrocelli    02/25/85
  4.     ;Rev by John R. Petrocelli    04/30/85
  5.     ;Rev by Durrell Drummond    10/10/86
  6.     ;Re-written by Bob Montgomery    01/10/87
  7.     ;Re-written by John Jaeger    03/12/89
  8.  
  9.     ;Major changes include ready for assembly by MASM.
  10.  
  11.     ;Use without the ANSI.SYS driver for reasonable CRT
  12.     ;displays.
  13.  
  14.     ;Corrected source code.  The original dated 01/10/87
  15.     ;worked as stated when using the supplied object code,
  16.     ;However when I added all the necessary items to compile
  17.     ;with MASM, things didn't work so well.  That may be due
  18.     ;to the fact I am not acquainted with A86!
  19.  
  20.     ;Coding of the ASCII Password string so that if
  21.     ;viewed by such things as XTREE, nothing jumps out
  22.     ;and indicates a readable password.
  23.  
  24.     ;Coding of the "Prompt Strings" for the same reason
  25.     ;as noted above.  There is no evidence that this file
  26.     ;is the one to cause the Password Check to appear on the 
  27.     ;screen.
  28.  
  29. code    segment public    'CODE'
  30.  
  31.     assume cs:code,ds:code,es:code
  32.  
  33. driver    proc    near
  34.  
  35.     org    0                ;Required for Device Driver
  36.  
  37. ;======== Driver Device Header Area ========
  38.  
  39. header:    dd    -1                ;One device in this file
  40.     dw    8000h                ;Defines character device
  41.     dw    strategy            ;Pointer to install routine
  42.     dw    interrupt            ;pointer to proc that handles
  43.                         ;the services
  44.     db    'PWXYZQPR'            ;8 byte string that names the
  45.                         ;device.  Do not attempt to
  46.                         ;type from the Keyboard or
  47.                         ;anything could happen!!!!
  48.  
  49. ;============================================================================
  50.  
  51. ;======== Storage for header offset and segment ========
  52. rhoffset     dw    0
  53. rhseg        dw    0
  54. ;============================================================================
  55.  
  56. ;============================================================================
  57. ;Area below is for some variables used by the program that installs
  58. ;PASSWORD.SYS.  DO NOT change the relationship of the variable "area_length"
  59. ;to the DEVICE HEADER, or the location of the PASSWORD area!  You may add
  60. ;or delete to the Screen Message area, but do not move or remove the 
  61. ;"tries_left" variable in relation to the message area.
  62. ;============================================================================
  63. area_length    dw    tries_left-$
  64. password    db    0
  65. password_len    equ    $-password
  66. padd        db    16-password_len dup(20h)
  67. ;============================================================================
  68.  
  69. ;======== Screen message character area (Encrypted) ========
  70.  
  71. msg_1        db    'Enter Password:',15 dup(20h)    ;Enter Password
  72. msg_1_len    dw    $-msg_1                
  73. msg_2        db    '****** Password Accepted *****';Password Accepted
  74. msg_2_len    dw    $-msg_2
  75. msg_3        db    '** Wrong Password Try Again **';Wrong Password
  76. msg_3_len    dw    $-msg_3
  77. msg_4        db    '******** ACCESS DENIED *******';Access Denied
  78. msg_4_len    dw    $-msg_4
  79. msg_5        db    201,32 dup(205),187        ;Screen Box
  80. msg_6        db    186,32 dup(20h),186        ;Screen Box
  81. msg_7        db    200,32 dup(205),188        ;Screen Box
  82. ;============================================================================
  83. ;Miscellaneous Variable Storage
  84. ;============================================================================
  85. Tries_left    db    0
  86. wordlen        db    0
  87. wordbuff    db    15 dup(0)
  88. tries        db    3
  89. breakoff    dw    0
  90. breakseg    dw    0
  91. video_location    dw    0
  92. cursor_location    dw    0
  93. ;============================================================================
  94. dummyret:    iret                ;Pointer to Ctrl-Break vector
  95.                         ;inserted by this program to
  96.                         ;disable the Ctrl-Break 
  97. ;============================================================================
  98.  
  99. ;======== main portion of program to get the user password ========
  100.  
  101. ask_password:
  102.  
  103.     push    cs
  104.     pop    ds                ;Set ds=cs
  105.     mov    ax,351bh            ;Get break vector (Int 1Bh)
  106.     int    21h                ;from DOS
  107.     mov    breakoff,bx            ;Save it for later
  108.     mov    breakseg,es
  109.     push    cs
  110.     pop    es                ;Set es=cs
  111.     mov    dx,offset dummyret        ;Set Break vector to dummyret
  112.     mov    ax,251bh
  113.     int    21h                ;via DOS
  114.  
  115. check_video:                    ;See where video RAM is
  116.  
  117.     mov    ah,0fh                ;via video ROM
  118.     int    10h                
  119.     cmp    al,07h                ;See if Mono card installed
  120.     jz    set_mono            ;Jump to monochrome routine
  121.  
  122.     mov    video_location,0b800h        ;If not mono then Color RAM
  123.     jmp    video_done            ;Exit routine
  124.  
  125. set_mono:
  126.  
  127.     mov    video_location,0b000h        ;Set location to Mono RAM
  128.  
  129. video_done:
  130.  
  131.     call    clear_screen            ;Self explanatory
  132.  
  133.     call    box                ;Routine to build entry
  134.                         ;box on screen
  135.     xor    cx,cx                ;Set cx=0
  136.     mov    cl,tries            ;Store the number of tries
  137.     mov    tries_left,cl            ;for later
  138.  
  139. ;======== Prompt the user for the correct password ========
  140.  
  141. set_prompt:
  142.  
  143.     cmp    cl,0                ;See if tries has expired
  144.     jz    go_lock_out            ;Jump to routine to lock
  145.                         ;system if tried 3 times
  146.                         ;with wrong password!
  147.  
  148.     mov    tries_left,cl            ;Store the tries left
  149.     mov    bx,offset msg_1            ;Point to input prompt
  150.     mov    cx,msg_1_len            ;Prep for display
  151.     mov    ah,0fh                ;Set ah with the attribute
  152.                         ;that write_crt uses
  153.                         ;You may change this for
  154.                         ;different colors or intensity
  155.     mov    dx,0c19h            ;Load dx for start location
  156.     call    write_crt            ;to print on CRT and write it
  157.  
  158.     mov    dx,0b27h            ;Set CRT location for input
  159.                         ;field start
  160.     xor    bx,bx                ;Set bx to 0 (Page 0)
  161.     call    position_cursor            ;Set cursor to start of input
  162.                         ;line on CRT
  163.     mov    si,offset wordlen        ;Point to number of char. in
  164.     mov    byte ptr [si],0            ;entry and initialize to 0
  165.     mov    di,offset wordbuff        ;Point to number of char. in
  166.                         ;stored password
  167. ;======== Character input routine ========
  168.  
  169. in_char:                    ;Lets go get some input
  170.  
  171.     mov    ah,07h                ;Use none echoing input
  172.     int    21h                ;from DOS
  173.     cmp    al,08h                ;See if backspace?
  174.     jz    back_space            ;Jump to routine to del Char.
  175.     cmp    al,0dh                ;See if input is done?
  176.     jz    check_password            ;Check it out
  177.     cmp    byte ptr [si],15        ;See if password length has
  178.     jz    bell                ;been exceeded and ring bell
  179.     mov    [di],al                ;Store char in wordbuff and
  180.     inc    di                ;increment pointer
  181.     mov    al,0h                ;Store special char for the
  182.     call    write_cursor            ;display of an '*' on the CRT
  183.     jmp    in_char                ;Loop for the next Character
  184.  
  185. ;======== Intermediate launching point to lock the machine ========
  186.  
  187. go_lock_out:
  188.  
  189.     call    lock_out            ;Go lock up the machine
  190.  
  191. ;======== Routine to back space and erase on the crt ========
  192.  
  193. back_space:
  194.  
  195.     cmp    byte ptr [si],0            ;See if there are no char to
  196.     jz    bell                ;erase and sound bell if none
  197.     dec    byte ptr [si]            ;Set char count to one less
  198.     dec    di                ;Move pointer back one in
  199.                         ;wordbuff
  200.     mov    al,0ffh                ;Set erase code for erasing
  201.     call    write_cursor            ;'*' at cursor position
  202.     jmp    in_char                ;Loop back for next char
  203.  
  204. ;======== Ring the bell routine ========
  205.  
  206. Bell:    mov    al,07h                ;Ring the bell with DOS
  207.     mov    ah,0eh
  208.     int    10h
  209.     jmp    in_char                ;Back to input
  210.     
  211. ;============================================================================
  212. ;End of input routines, now lets go check what was entered!
  213. ;============================================================================
  214.  
  215. Check_password:
  216.  
  217.     mov    di,offset password        ;Point to length of our pre-
  218.     cmpsb                    ;set word and see if the 
  219.     jne    next_try            ;length is the same and spare
  220.                         ;the trouble if it is not
  221.  
  222.     xor    cx,cx                ;cx=0
  223.     mov    cl,wordlen            ;Total char. entered into cl
  224.     call    convert_up            ;Convert char. to upper case
  225.     repe    cmpsb                ;compare pointers si & di
  226.     cmp    cl,0                ;See if all matched
  227.     je    ok                ;Jump to exit if they were
  228.                         ;Fall through if not
  229.  
  230. ;======== Routine to display wrong word and reset for another word ========
  231.  
  232. next_try:
  233.  
  234.     call    off_screen            ;Move curser out of the box
  235.     mov    dx,0c19h            ;Cursor location for message
  236.     mov    bx,offset msg_3            ;Wrong Password message
  237.     mov    cx,msg_3_len            ;Message length
  238.     mov    ah,8fh                ;Blinking attribute
  239.     call    write_crt            ;Display message
  240.     mov    ax,0e07h            ;Ring bell
  241.     int    10h
  242.     mov    ah,07h                ;Ask for character input to
  243.     int    21h                ;hold screen. Any char allows
  244.                         ;continuation of the program
  245.     mov    cl,tries_left            ;Set up to reduce the number
  246.     dec    cl                ;of tries left and go back
  247.     jmp    set_prompt            ;for another turn
  248.  
  249. ;======== This is where we prepare to exit this program ========
  250.  
  251. ok:
  252.  
  253.     call    off_screen            ;Move cursor out of th